﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.Generic;
using System.ComponentModel;

namespace SilverlightShared
{
    public class TaxiCustomer : INotifyPropertyChanged
    {
        private string _Name;
        private string _PickupAdress;
        private string _DestinationAddress;
        private string _SpecialInstruction;
        private string _MobileNo;
        private string _TelNo;
        private string _TravelDateStr;
        private DateTime _TravelDate;
        private int _VehicleType;

        public TaxiCustomer()
        {
            TravelNow = true;
            _TravelDate = DateTime.Now;
        }
                                              
        public GeoCoordinate PickupCoordinates { get; set; }
        public GeoCoordinate DropoffCoordinates { get; set; }
        
        public bool TravelNow { get; set; }

        public string Name
        {
            get
            {
                return _Name;
            }
            set
            {
                _Name = value;
                NotifyPropertyChanged("Name");
            }
        }


        public string MobileNo
        {
            get
            {
                return _MobileNo;
            }
            set
            {
                _MobileNo = value;
                NotifyPropertyChanged("MobileNo");
            }
        }
        
        public string TelNo
        {
            get
            {
                return _TelNo;
            }
            set
            {
                _TelNo = value;
                NotifyPropertyChanged("TelNo");
            }
        }

        public DateTime TravelDate
        {
            get
            {
                return _TravelDate;
            }
            set
            {
                _TravelDate = value;
                TravelDateStr = _TravelDate.ToLongDateString() + "  " + _TravelDate.ToShortTimeString();
                NotifyPropertyChanged("TravelDate");
            }
        }

        public string PickupAddress 
        {
            get
            {
                return _PickupAdress;
            }
            set
            {
                _PickupAdress = value;
                NotifyPropertyChanged("PickupAddress");
            }
        }

        public string DestinationAddress
        {
            get
            {
                return _DestinationAddress;
            }
            set
            {
                _DestinationAddress = value;
                NotifyPropertyChanged("DestinationAddress");
            }
        }

        public string SpecialInstruction
        {
            get
            {
                return _SpecialInstruction;
            }
            set
            {
                _SpecialInstruction = value;
                NotifyPropertyChanged("SpecialInstruction");
            }
        }

        public int VehicleType
        {
            get
            {
                return _VehicleType;
            }
            set
            {
                _VehicleType = value;
                NotifyPropertyChanged("VehicleType");
            }
        }

        public string VehicleTypeStr 
        {
            get
            {
                TaxiType tt = (TaxiType)VehicleType;

                switch (tt) {
                    case TaxiType.FourSeatSedan:
                        return "Four seat sedan";   
                    case TaxiType.SevenSeater:
                        return "Seven seater";
                    case TaxiType.TenSeater:
                        return "Ten seater";
                    case TaxiType.Stationwagon:
                        return "Stationwagon";
                    case TaxiType.Executive:
                        return "Executive";
                    case TaxiType.Limousine:
                        return "Limousine";
                    case TaxiType.SpecialNeeds:
                        return "Special needs";
                    default:
                        return "Four seat sedan";
                }
            }
        }

        public string TravelDateStr 
        {
            get
            {
                return _TravelDateStr;
            }
            set
            {
                _TravelDateStr = value;
                NotifyPropertyChanged("TravelDateStr");
            }
        }

        // NotifyPropertyChanged will raise the PropertyChanged event, 
        // passing the source property that is being updated.
        public void NotifyPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, 
                    new PropertyChangedEventArgs(propertyName));
            }
        }

        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;

        #endregion
    }

    public class TaxiDriver
    {
        public string LicenseNo { get; set; }
        public int ETAinMunites { get; set; }
        public override string ToString()
        {
            return string.Format("{0} E.T.A {1} munites", LicenseNo, ETAinMunites);
        }
    }

    public enum TaxiType { FourSeatSedan = 0, Stationwagon=1, SevenSeater=2, TenSeater=3, Executive=4, SpecialNeeds=5, Limousine=6 };
    public enum JobStatus { jsDeclined, jsTerminated, jsCompleted };
    public delegate void PushJobDelegate (int jobID);

    public class Job
    {
        #region Private Variables
        private List<string> _DeclinedTaxis;
        #endregion

        #region Constructor
        public Job()
        {
            _DeclinedTaxis = new List<string>();
        }
        #endregion

        #region Public Methods
        public void AddDecliningTaxi(string licenseNo)
        {
            if (_DeclinedTaxis.IndexOf(licenseNo) == -1)
                _DeclinedTaxis.Add(licenseNo);
        }
        #endregion

        #region Properties
        public int JobID { get; set; }
        public DateTime DispatchTime { get; set; }
        #endregion
    }

    public class TaxiCommon
    {
       public static string GetVehicleType(TaxiType taxiType)
        {
            switch (taxiType)
            {
                case TaxiType.FourSeatSedan:
                    return "Four seat sedan";
                case TaxiType.SevenSeater:
                    return "Seven seater";
                case TaxiType.TenSeater:
                    return "Ten seater";
                case TaxiType.Stationwagon:
                    return "Stationwagon";
                case TaxiType.Executive:
                    return "Executive";
                case TaxiType.Limousine:
                    return "Limousine";
                case TaxiType.SpecialNeeds:
                    return "Special needs";
                default:
                    return "Four seat sedan";
            }
        } 
    }
}
